package com.topInterview;

public class leecode121 {
    public int maxProfit(int[] arr) {
        if (arr == null || arr.length < 1) {
            return 0;
        }
        int min = arr[0];
        int ans = 0;
        for (int i = 0; i < arr.length; i++) {
            min = Math.min(min, arr[i]);
            ans = Math.max(ans, arr[i] - min);
        }
        return ans;
    }
}
